// pages/questionnaireReport/questionnaireReport.js
const app = getApp()
let wxparse = require("../../wxParse/wxParse.js");
Page({
	data: {
		dkheight:300,
    	dkcontent: "<b>正在加载问卷报告...</b >",
	},
	onLoad(options) {
		 //获得参数
		options.qnNo ? this.setData({qnNo:options.qnNo}) : null;
		
		 // 获得高度
		 let winPage = this;
		 wx.getSystemInfo({
		   success: function (res) {
			 let winHeight = res.windowHeight;
			 console.log(winHeight);
			 winPage.setData({
			   dkheight: winHeight - 60
			 })
		   }
		 })
	},
	onShow: function (options) {
		/* post提交数据 */
		wx.showLoading({title:"加载中..."})
		wx.request({
			url: `${app.globalData.server_request_baseUrl}/user_getQnReportDetail.php`,
			data: {
				// openid: wx.getStorageSync('openid'),
				qnNo : this.data.qnNo
				// unionid: wx.getStorageSync('unionid')
			},
			header: {'Content-Type': 'application/x-www-form-urlencoded'},
			method: 'GET',
			dataType: 'json',
			responseType: 'text',
			success: (res) => {
				if (res.data.code == 0) {
					wx.showToast({ title: '加载成功！' })
					let reportStr = res.data.data.report
					this.setData({ dkcontent: reportStr }, () => { 
						wxparse.wxParse('dkcontent', 'html', this.data.dkcontent, this, 5);
					})
				} else { 
					wx.showToast({ title: '补充消息失败！' })
				}
			},
			fail: () => { wx.showToast({ title: '请求失败' })},
			complete: () => {wx.hideLoading()}
		});
	}
})